package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

@Getter
@Setter
public class Comment {

    private Long id; //id

    private Integer star; //几颗星

    private String content; //点评文本内容
    private String uNickName; //点评文本内容
    private String uHeadImgUrl; //点评文本内容

    private Long userId; //用户id,也就是点评者

    private Long strategyId; //点评的攻略id
    private String sCoverUrl;
    private String sTitle;

    private String picUrl; //图片的url
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date releaseTime;

    private List singlePic=new ArrayList<>();

    public String getJson(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("content",content);
        String[] split = picUrl.split(",");
        ArrayList<Object> picList = new ArrayList<>();
        for (String s : split) {
            HashMap<String, String> map2 = new HashMap<>();
            map2.put("pic",s);
            picList.add(map2);
        }
        setSinglePic(picList);
        map.put("singlePic",singlePic);
        return JSONUtil.toJSONString(map);
    }

}